package org.grow.loginto.filter;

import org.springframework.stereotype.Service;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author: xwg
 * @CreateDate: 21-6-14
 */
@Service
public class LeaveCountFilter implements Filter {

    private AtomicInteger count = new AtomicInteger(0);
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        if (request.getRequestURI().contains("leave")){
            int i = count.incrementAndGet();
            System.out.println("当前leave相关业务模块总访问量为: "+i);
        }
        filterChain.doFilter(servletRequest,servletResponse);
    }
}
